/*
 * DCRawCommand.java
 *
 * Created on 30 de Junho de 2005, 15:20
 */

package jhub.text;

import java.io.UnsupportedEncodingException;
import java.util.Date;

/**
 *
 * @author  botelhodaniel
 */
public class DCRawCommand implements Command{
    private Date timeStamp;
    protected String command;
    
    /** Creates a new instance of DCRawCommand */
    public DCRawCommand(String command) {
        this.command = command.endsWith("|") ? command : command+"|";
        this.timeStamp = new Date();
    }
    
    public DCRawCommand(Date timeStamp,String command) {
        this.command = command.endsWith("|") ? command : command+"|";
        this.timeStamp =(timeStamp==null)? new Date():timeStamp;
    }
    
    public byte[] getBytes() throws UnsupportedEncodingException{
        return command.getBytes("ISO-8859-1");
    }
    
    public boolean is(String type){
        return command.startsWith(type);
    }
    
    public DCRawCommand getCommand() {
        return this;
    }
    
    public String toString(){
        return command;
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
    }
    
}
